Skip to content

Prevent <a> tag from being focusable (via tabbing) when inside <Disabled> component. - #24397

Merged
youknowriad merged 2 commits into
WordPress:masterfrom
yansern:fix/handle-anchor-tag-for-disabled-component
Aug 12, 2020
Merged

youknowriad merged 2 commits into
WordPress:masterfrom
yansern:fix/handle-anchor-tag-for-disabled-component

Conversation

@yansern

@yansern yansern commented Aug 6, 2020 •

Copy link
Copy Markdown
Contributor

When <a> tag is inside the <Disabled>, it is focusable via tabbing, therefore causing unintended consequences.

One such example is when the <a> tag presents itself inside block previews on block pattern list on the block inserter menu, it causes the <a> to receive focus, and activates the block toolbar unintentionally.

See more detail of this issue at: Automattic/wp-calypso#44042

Description

Set tabindex=-1 specifically on <a> nodes when inside <Disabled> component.

How has this been tested?

  1. Tab through the block pattern list.
  2. It should not activate the block toolbar.

Screenshots

See Automattic/wp-calypso#44042

Types of changes

Bug fix

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@youknowriad youknowriad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me.

focusable.setAttribute( 'disabled', '' );
}

if ( focusable.nodeName=='A' ) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are some linting issues here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants